<?php
namespace Mp\Service\Grid;

use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Builder;

class Pager  {

	protected $builder;

	public $source;

	protected $pagesize = 15;


	protected $data = [];

	protected $view = "Mp::grid.pager";

	/*public function __construct(){
		
	}*/

	public function view($view=null){
		$this->view = $view;
		return $this;
	}

	public function builder($content){
		if($content instanceof Builder){
			$this->builder = $content;
		}elseif($content instanceof Closure){
			call_user_func($content,$this);
		}

		return $this;
		
	}


	public function data(){
		return [
			'links' => $this->links(),
		];
	}

	public function paginate($pagesize = 15){

		$this->pagesize = $pagesize;
		$this->source = $this->builder->paginate($this->pagesize);

	}
	
	public function source(){
		return $this->source;
	}

	public function links(){
		
		return $this->source->links($this->view);
	}

	
	

}